const {response} = require("express");
const Logger = require("../core/utils/Logger");
const {RaUser} = require("../database/modes");
const {database} = require("../app");
const userService = require("../service/UserService");
const {BaseController} = require("../core/base/BaseController");

class UserController extends BaseController {


    /**
     * 分页查询 系统用户列表
     */
    querySystemUsers() {
        return (req, rep) => {
            Logger.d("用户表分页查询开始.....")
            rep.send(JSON.stringify({"username": "111"}))
        }
    }


    /**
     * 用户登录
     */
    login() {
        return (req, resp) => {
            let {username, password} = req.body;
            userService.userLogin({
                username, password
            }).then(res => {
                if (res == null ){
                    this.success(resp,"登录成功" , {})
                }else {
                    this.error(resp, res, {});
                }
            })

        }
    }

    /**
     * 用户注册
     */
    register() {
        return (req, resp) => {
            let {username, password} = req.body;
            userService.userRegister({
                username, password
            }).then(res => {
                this.response(resp, res, {});
            })
        }
    }
}


const userController = new UserController()

module.exports = userController





